package HomeWork;

public class Demo10 {
    public static void main(String[] args) {
        int n = 5;
        long result = calculation(n);
        System.out.println(n + "! = " + result);
    }
    public static long calculation(int n) {
        if (n < 0) {
            throw new IllegalArgumentException("n 不能为负数");
        }
        if (n == 0 || n == 1) {
            return 1;
        }
        return n * calculation(n - 1);
    }
}
